﻿Imports System.Collections.Specialized


Public Class VMStep
    Inherits VMBase

    Dim _NextStep As VMStep
    Dim _PreviousStep As VMStep
    Dim _StartStep As VMStep
    Dim _ParentStep As VMStep
    Dim _Steps As New VMStepCollection

    Public Property Title As String
    Public Property Active As Boolean

    Sub New()

    End Sub
    Sub New(ByVal after As VMStep)
        _PreviousStep = after
        after._NextStep = Me
        If _ParentStep IsNot Nothing Then
            _ParentStep._Steps.Add(after)
        End If
    End Sub

    Public ReadOnly Property NextStep As VMStep
        Get
            Return _NextStep
        End Get
    End Property

    Public ReadOnly Property PreviousStep As VMStep
        Get
            Return _PreviousStep
        End Get
    End Property

    Public Property StartStep As VMStep
        Get
            Return _StartStep
        End Get
        Set(ByVal value As VMStep)
            _StartStep = value
            _StartStep._ParentStep = Me
            _Steps.Add(_StartStep)
        End Set
    End Property
    Public Function AddAfter(ByVal title As String) As VMStep
        Dim result = New VMStep() With {.Title = title}
        If _ParentStep IsNot Nothing Then
            _ParentStep._Steps.Add(result)
        End If
        result._ParentStep = _ParentStep
        result._PreviousStep = Me
        Me._NextStep = result
        Return result
    End Function

    Public ReadOnly Property Steps As VMStepCollection
        Get
            Return _Steps
        End Get
    End Property

    Public Property Element As VMElement


End Class

Public Class VMStepCollection
    Inherits VMBase
    Implements INotifyCollectionChanged
    Implements IList(Of VMStep)

    Private container As New List(Of VMStep)

#Region "INotifyCollectionChanged Implementation"

    Private Event CollectionChanged(ByVal sender As Object, ByVal e As System.Collections.Specialized.NotifyCollectionChangedEventArgs) Implements System.Collections.Specialized.INotifyCollectionChanged.CollectionChanged

    Protected Sub OnCollectionChangedAdd(ByVal newitem As Object)
        RaiseEvent CollectionChanged(Me, New NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newitem))
    End Sub
    Protected Sub OnCollectionChangedRemove(ByVal olditem As Object)
        RaiseEvent CollectionChanged(Me, New NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, olditem))
    End Sub
#End Region

#Region "IList Implementation"


    Public Sub Add(ByVal item As VMStep) Implements System.Collections.Generic.ICollection(Of VMStep).Add
        container.Add(item)
        OnPropertyChanged("Count")
        OnCollectionChangedAdd(item)
    End Sub

    Private Sub Clear() Implements System.Collections.Generic.ICollection(Of VMStep).Clear

    End Sub

    Private Function Contains(ByVal item As VMStep) As Boolean Implements System.Collections.Generic.ICollection(Of VMStep).Contains

    End Function

    Private Sub CopyTo(ByVal array() As VMStep, ByVal arrayIndex As Integer) Implements System.Collections.Generic.ICollection(Of VMStep).CopyTo

    End Sub

    Public ReadOnly Property Count As Integer Implements System.Collections.Generic.ICollection(Of VMStep).Count
        Get
            Return container.Count
        End Get
    End Property

    Private ReadOnly Property IsReadOnly As Boolean Implements System.Collections.Generic.ICollection(Of VMStep).IsReadOnly
        Get
            Return False
        End Get
    End Property

    Public Function Remove(ByVal item As VMStep) As Boolean Implements System.Collections.Generic.ICollection(Of VMStep).Remove
        Dim result = container.Remove(item)
        OnPropertyChanged("Count")
        OnCollectionChangedAdd(item)
        Return result
    End Function

    Private Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of VMStep) Implements System.Collections.Generic.IEnumerable(Of VMStep).GetEnumerator
        Return container.GetEnumerator()
    End Function

    Private Function IndexOf(ByVal item As VMStep) As Integer Implements System.Collections.Generic.IList(Of VMStep).IndexOf

    End Function

    Private Sub Insert(ByVal index As Integer, ByVal item As VMStep) Implements System.Collections.Generic.IList(Of VMStep).Insert

    End Sub

    Default Public Property Item(ByVal index As Integer) As VMStep Implements System.Collections.Generic.IList(Of VMStep).Item
        Get
            Return container(index)
        End Get
        Set(ByVal value As VMStep)

        End Set
    End Property

    Private Sub RemoveAt(ByVal index As Integer) Implements System.Collections.Generic.IList(Of VMStep).RemoveAt

    End Sub

    Private Function GetEnumerator1() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
        Return container.GetEnumerator()
    End Function

#End Region

End Class

Partial Public Class VMTableauSuivi
    Inherits VMBase
    Implements OMANE.Common.UI.IViewModelTabSection

    Private _Steps As New VMStepCollection

    Sub New()

    End Sub

    Public ReadOnly Property Steps As VMStepCollection
        Get
            Return _Steps
        End Get
    End Property

  
    Public ReadOnly Property CurrentStep As String
        Get

        End Get
    End Property


#Region "IViewModelTabSection Implementation"

    Public Property Icone As String Implements Common.UI.IViewModelTabSection.Icone
        Get

        End Get
        Set(ByVal value As String)

        End Set
    End Property

    Public Property Title As String Implements Common.UI.IViewModelTabSection.Title
        Get
            Return "Tableau de Suivi"
        End Get
        Set(ByVal value As String)

        End Set
    End Property

#End Region

    

End Class


Public Class VMElement
    Inherits VMBase

    Dim _State As String


    Public ReadOnly Property State As String
        Get
            Return _State
        End Get
    End Property

    Public Event StateInitializing As EventHandler(Of StateEventArgs)
    Public Event StateInitialized As EventHandler(Of StateEventArgs)


    Public Property Configure As Windows.Input.ICommand

    Public Property Execute As Windows.Input.ICommand
End Class


Public Class VMSASComputationElement
    Inherits VMElement



End Class


Public Class StateEventArgs
    Inherits EventArgs

    Public Property PreviousState As String
    Public Property NextState As String
End Class

